﻿using ServiceStack;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;

namespace vueweb
{
	public class RegisterRedis
	{
		public static void Register()
		{
			LicenseKey licenseKey = new LicenseKey();
			licenseKey.Type = LicenseType.Enterprise;

			Type t = typeof(LicenseUtils);
			FieldInfo f = t.GetField("__activatedLicense", BindingFlags.GetField | BindingFlags.NonPublic | BindingFlags.Static);
			string fType = f.FieldType.Name;

			if (fType == "LicenseKey")
			{
				f.SetValue(null, licenseKey);
			}
			else if (fType == "__ActivatedLicense")
			{
				Type[] ts = t.GetNestedTypes(BindingFlags.NonPublic);
				Type t2 = ts[0];
				object obj = Activator.CreateInstance(t2, BindingFlags.NonPublic | BindingFlags.Instance, null, new object[] { licenseKey }, null);
				f.SetValue(null, obj);
			}
		}
	}
}
